<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class About_model extends CI_Model
{
    public $about_id;
    public $title;
    public $contents;
    public function __construct()
    {
        parent::__construct();
        $this->load->database();
    }

    public function Get_AllRow()
    {
        return $this->db->count_all_results('about');
    }  

    public function Add_About($aboutModel)
    {
        $this->db->insert('about',$aboutModel);
        return $this->db->affected_rows(); 
    }

    public function Get_About_ById($about_id)
    {
        return $this->db->select()->from('about')->where('about_id='.$about_id)->get()->row();
    }
    public function Get_About_ByParentId($parentid)
    {
        return $this->db->select()->from('about')->where('parentid='.$parentid)->get()->row();
    }


    public function Edit_About($aboutModel)
    {
        $this->db->update('about',$aboutModel,array('about_id'=>$aboutModel->about_id));
        return $this->db->affected_rows();
    }
    public function Get_About_First()
    {
        return $this->db->select()->from('about')->where('about_id>0')->get()->row();
    }

    public function DelAbout_ById($about_id)
    {
        $this->db->delete('about',array('about_id'=>$about_id));
        return $this->db->affected_rows();
    }
}
?>